# _*_ coding : utf-8 _*_
# @Time : 2022/8/7 18:49
# @Author : Moonquake
# @File : 10.quote方式
# @Project : python
import urllib.request
import urllib.parse
url='https://www.baidu.com/s?wd='
headers ={
    'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.5112.81 Safari/537.36 Edg/104.0.1293.47'
}

# 将周杰伦三个字转换成Unicode编码格式
# 依赖于urllib.parse
name =urllib.parse.quote('周杰伦')
url =url+name

# 请求对象定制
request = urllib.request.Request(url=url,headers=headers)
# 模拟浏览器发送请求
response =urllib.request.urlopen(request)
# 获取响应内容
content = response.read().decode('utf-8')
print(content)
